翻訳と辞書 |
method chaining : ウィキペディア英語版 | method chaining
Method chaining, also known as named parameter idiom, is a common syntax for invoking multiple method calls in object-oriented programming languages. Each method returns an object, allowing the calls to be chained together in a single statement without requiring variables to store the intermediate results. Local variable declarations are syntactic sugar because of the difficulty humans have with deeply nested method calls.〔(【引用サイトリンク】title=Session 18Variable References )〕〔(【引用サイトリンク】title=CMSC 631 – Program Analysis andUnderstanding )〕 A method chain is also known as a ''train wreck'' due to the increase in the number of methods that come one after another in the same line that occurs as more methods are chained together even though line breaks are often added between methods. A similar syntax is method cascading, where after the method call the expression evaluates to the current object, not the return value of the method. Cascading can be implemented using method chaining by having the method return the current object itself. Cascading is a key technique in fluent interfaces, and since chaining is widely implemented in object-oriented languages while cascading isn't, this form of "cascading-by-chaining by returning this" is often referred to simply as "chaining". Both chaining and cascading come from the Smalltalk language. While chaining is syntax, it has semantic consequences, namely that requires methods to return an object, and if implementing cascading via chaining, this must be the current object. This prevents the return value from being used for some other purpose, such as returning an error value, and requires that the return value be mutable (e.g., the original object, not a copy). == Examples ==
抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「method chaining」の詳細全文を読む
スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース |
Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.
|
|